package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.CameraMapper;
import com.xxx.modules.entity.Camera;
import com.xxx.modules.service.CameraService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * camera
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@Service
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements CameraService {

    @Autowired
    private CameraMapper cameraMapper;


    @Override
    public PageInfo<Camera> selectCameraInfo(Camera camera, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Camera> wrapper = new QueryWrapper<>();
        List<Camera> data = cameraMapper.selectListInfo(camera);
        return new PageInfo<>(data);
    }

    @Override
    public void saveCameraInfo(Camera camera) {
        camera.setCreatreTime(TimeUtil.getCurrentTime());
        cameraMapper.insert(camera);
    }

    @Override
    public void updateCameraInfo(Camera camera) {
        cameraMapper.updateById(camera);
    }

    @Override
    public void delCameraInfo(Integer id) {
        cameraMapper.deleteById(id);
    }

    @Override
    public void delBatchCameraInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        cameraMapper.deleteBatchIds(list);
    }


}